<template>
  <div class="page">
    <div class="layui-fluid">
      <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
          <div class="layui-card">

            <div class="layui-card-body">
              <div class="layui-form" lay-filter="">
                <div class="layui-form-item">
                  <label class="layui-form-label">商品名称</label>
                  <div class="layui-input-block" style="width: 190px;">
                    <input type="text" disabled="disabled" name="name" placeholder="输入商品名称" v-model="itemData.name"
                      autocomplete="off" class="layui-input a">
                  </div>
                </div>
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">商品图片</label>
                    <div class="layui-input-inline" style="width: 180px;">
                      <div class="layui-upload">
                        <button type="button" class="layui-btn" id="layuiadmin-upload-useradmin">选择文件</button>
                      </div>
                    </div>
                  </div>
                </div>
                <div class="layui-form-item">
                  <div class="layui-inline">
                    <label class="layui-form-label">图片预览</label>
                    <div class="layui-input-inline" style="width: 180px;">
                      <img id="img" :src="itemData.logoUrl?itemData.logoUrl:require('@/assets/zwyl.jpg')"
                        style="width:100px;height:100px;">
                    </div>
                  </div>
                </div>
                <div class="layui-form-item">
                  <label class="layui-form-label">所选门店</label>
                  <div class="layui-input-block" style="width: 190px;">
                    <input type="text" disabled="disabled" placeholder="" v-model="itemData.shop.shopName"
                      autocomplete="off" class="layui-input a">
                  </div>
                </div>
                <div class="layui-form-item">
                  <label class="layui-form-label">商品分组</label>
                  <div class="layui-input-block" style="width: 190px;">
                    <input type="text" disabled="disabled" placeholder="" v-model="itemData.itemGroupName"
                      autocomplete="off" class="layui-input a">
                  </div>
                </div>
                <div class="layui-form-item">
                  <label class="layui-form-label">经营类目</label>
                  <div class="layui-input-block" style="width: 190px;">
                    <input type="text" disabled="disabled" placeholder="" v-model="itemData.categoryName"
                      autocomplete="off" class="layui-input a">
                  </div>
                </div>
                <div class="layui-form-item">
                  <label class="layui-form-label">商品状态</label>
                  <div class="layui-input-inline">
                    <select name="activeStatus" lay-filter="activeStatus" v-model="itemData.activeStatus">
                      <option value="ENABLE">正常销售</option>
                      <option value="DISABLE">下架</option>
                    </select>
                  </div>
                </div>
                <div class="layui-form-item">
                  <label class="layui-form-label">推荐首页</label>
                  <div class="layui-input-inline">
                    <select name="ranking" lay-filter="ranking" v-model="itemData.ranking">
                      <option value="1">是</option>
                      <option value="0">否</option>
                    </select>
                  </div>
                </div>
                <div class="layui-form-item">
                  <label class="layui-form-label">库存</label>
                  <div class="layui-input-block" style="width: 190px;">
                    <input type="text" disabled="disabled" name="stockAmount" placeholder="输入商品库存"
                      v-model="itemData.saleStock.stockAmount" autocomplete="off" class="layui-input a">
                  </div>
                </div>
                <div class="layui-form-item">
                  <label class="layui-form-label">售价</label>
                  <div class="layui-input-block" style="width: 190px;">
                    <input type="number" disabled="disabled" name="specialPrice" placeholder=""
                      v-model="itemData.price.specialPrice" autocomplete="off" class="layui-input a">
                  </div>
                </div>
                <div class="layui-form-item">
                  <label class="layui-form-label">原价</label>
                  <div class="layui-input-block" style="width: 190px;">
                    <input type="number" disabled="disabled" name="marketPrice" placeholder="非必填,默认售价1.5倍"
                      v-model="itemData.price.marketPrice" autocomplete="off" class="layui-input">
                  </div>
                </div>
                <div class="layui-form-item">
                  <label class="layui-form-label">产品重量</label>
                  <div class="layui-input-block" style="width: 190px;">
                    <input type="text" disabled="disabled" name="weight" placeholder="(克),非必填,不填则默认"
                      v-model="itemData.weight" autocomplete="off" class="layui-input">
                  </div>
                </div>
                <div class="layui-form-item">
                  <label class="layui-form-label">详情概述</label>
                  <div class="layui-input-block">
                    <div class="layui-upload">
                      <button type="button" class="layui-btn" id="test2">多图片上传</button>
                      <button type="button" class="layui-btn layui-btn-warm" @click="delimg">清除图片</button>
                      <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                        预览图：
                        <div class="layui-upload-list" style="width: 100%;" id="demo2"></div>
                      </blockquote>

                      <!-- <div class="layui-input-inline" style="width: 180px;">
                        <img id="demo2"
                          :src="itemData.itemPictureList?itemData.itemPictureList:require('@/assets/zwyl.jpg')"
                          style="width:100px;height:100px;">
                      </div> -->
                    </div>
                  </div>
                </div>
                <!--<div class="layui-form-item">
										<div class="layui-input-block">
											<button class="layui-btn layui-btn-normal" lay-submit lay-filter="setmyinfo" @click="confirmOk">确认</button>
										</div>
									</div>-->

              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>

export default {
  name: 'wucshopmalldetail',
  data () {
    return {
      itemData: {
        logoUrl: "",
        activeStatus: 'ENABLE',
        detailcontent: "",
        ranking: '0',
        shopId: '',//门店
        itemGroupId: '',//组
        categoryId: '',//类目
        shop: {},

        itemPictureList: [
          {
            pictureUrl: '',
            ranking: '',
          }
        ],//商品图片
        saleStock: { stockAmount: '', },
        price: {
          marketPrice: '',//原价
          specialPrice: '',//售价
        },
      },
      shoplist: [],
      grouplist: [],//分组
      jylmlist: [],//经营类目    	
      goodsId: '', //商品ID 

    }
  },
  mounted () {
    var _this = this;
    window.getdates = this.getdates;
  },
  methods: {
    getdates: function (data) {//回选详情			
      var _this = this;
      _this.goodsId = data.id;
      // _this.itemData.itemPictureList = _this.itemData.createItemPictureList;
      var url = '/mallcredit/bapi/v1.9/item/' + data.shop.shopId + '/' + data.id
      ajaxRequest(url, 'GET', 'json', '', function (ret, err) {

        _this.itemData = ret.data;
        _this.itemData.price.marketPrice = ret.data.price.marketPrice /100;
        _this.itemData.price.specialPrice = ret.data.price.specialPrice /100;

        // alert(JSON.stringify(ret))
         if (ret.data.itemDescription) {
          _this.itemData.createItemPictureList =
            ret.data.itemDescription.samllDescription;
          var src = ret.data.itemDescription.samllDescription;
          $("#demo2").html(src);
        }

      })
    },
    delimg: function () {
      return;
    },
  },
  updated: function () {
    layui.use('form', function () {
      var form = layui.form;
      form.render();
      form.on("select(activeStatus)", function (data) {//状态										
        _this.itemData.activeStatus = data.value
      });
      form.on("select(ranking)", function (data) {//推荐										
        _this.itemData.ranking = data.value
      });
    });
  },
}
</script>
<style>
#J_imageView img {
  width: 400px;
  display: block;
}
</style>
